<!-- 计算属性 -->
<script setup lang="ts">
import { computed, onMounted, getCurrentInstance } from 'vue'

const name = 'test'

const nameChange = computed(() => name + '测试')

const nameChangeSetAndGet = computed({
  get() {
    console.log('get')
    return `${name}这是get`
  },
  set(newValue) {
    // 改变之后的newValue
    console.log('set')
    console.log(nameChangeSetAndGet.value)
    return `${newValue}通过set改变`
  }
})

onMounted(() => {
  nameChangeSetAndGet.value = 'taosong改变'
})
</script>

<template>
  <div>
    {{ nameChange }}
    {{ nameChangeSetAndGet }}
  </div>
</template>

<style lang="scss" scoped></style>
